package com.itboye.eweilisten.presenter;

import com.itboye.eweilisten.model.UpdateVersionBean;
import com.itboye.eweilisten.responsitory.UpdateResponsitory;
import com.itboye.eweilisten.volley.BasePresenter;
import com.itboye.eweilisten.volley.ICompleteListener;
import com.itboye.eweilisten.volley.ResultEntity;

import java.util.Observer;

/**
 * Created by boye009 on 2017/1/5.
 */

public class UpdatePresenter extends BasePresenter {
    public static String update_success = "_Update_success";
    public static String update_fail = "_Update_fail";

    public UpdatePresenter(Observer observer) {
        super(observer);
    }

    public void Update(UpdateVersionBean bean) {
        UpdateResponsitory updateVersionBean = new UpdateResponsitory(new ICompleteListener() {

            @Override
            public void success(ResultEntity result) {
                result.setEventTag(Tag_Success);
                result.setEventType(update_success);
                setChanged();
                notifyObservers(result);
            }

            @Override
            public void failure(ResultEntity result) {
                result.setEventTag(Tag_Success);
                result.setEventType(update_fail);
                setChanged();
                notifyObservers(result);
            }
        });
        updateVersionBean.setUpdateVersion(bean);
    }

    ;
}
